<template>
<!-- 根部必须有一个div：包含所有内容 -->
  <div>
      <Navigation :username = "username"></Navigation>






  </div>
</template>



<style>



</style>


<script>
import Navigation from "../../components/Navigation.vue"
import api from '../../utils/api.js'


export default {

  // 名字
  name: 'Home',

  // 数据
  data(){
    return {
      username:'',
    }
  },

  // 引入(注册)组件
  components:{
    Navigation
  },

  // 方法
  methods:{

  },

  mounted(){
    // 未登录跳转
    var path = api.api+"/user/state"
    this.axios
    .get(path)
    .then(response=>{
      console.log(response)
      if(response.data.state=="未登录"){
        this.$router.push({path:'/login'})
      }
      else{
        this.username=response.data.users[0].username
      }
    }) 
  },


}
</script>